package mapred.example;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.Partitioner;

public abstract class SubKeyPartitioner<K extends Writable, V extends Writable>
		implements Partitioner<K, V> {

	@Override
	public int getPartition(K key, V value, int N) {
		return Math.abs(this.getSubKey(key).hashCode() % N);
	}

	protected abstract K getSubKey(K key);

}
